package com.xiaozhi.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiaozhi.dao.BussinessComboMapper;
import com.xiaozhi.dao.PersionComboMapper;
import com.xiaozhi.entity.BussinessCombo;
import com.xiaozhi.entity.PersionCombo;
import com.xiaozhi.entity.WxOrder;
import com.xiaozhi.service.BussinessComboService;
import com.xiaozhi.service.PersionComboService;

@Service
public class PersionComboServiceImpl  extends ServiceImpl<PersionComboMapper, PersionCombo> implements PersionComboService{
    
    @Resource
    private BussinessComboMapper bussinessComboMapper;

    @Resource
    private PersionComboMapper persionComboMapper;
    @Override
    @Transactional
    public int add_persion_combo(WxOrder order)
    {
        //查询对应的套餐，添加到我的订单列表
        BussinessCombo combo = bussinessComboMapper.selectComboById(order.getComboId());
        PersionCombo pcombo = new PersionCombo();
        pcombo.setComboName(combo.getComboName());
        pcombo.setModeId(combo.getModeId());
        pcombo.setModeName(combo.getModeName());
        pcombo.setPrice(combo.getPrice());
        pcombo.setTokenCount(combo.getTokenCount());
        pcombo.setDesc(combo.getDesc());
        pcombo.setOrderId(order.getOrderId());
        pcombo.setOpenId(order.getOpenId());
        pcombo.setRemianTokenCount(combo.getTokenCount());
        return persionComboMapper.insert(pcombo);
    }
}
